package com.course.serviceImpl;

import java.util.Vector;

import com.course.bean.ExamTo;
import com.course.daoI.ExamDAOI;
import com.course.daoImpl.ExamDaoImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.serviceI.ExamServiceI;

public class ExamServiceImpl implements ExamServiceI{
	
	ExamDAOI edao=new ExamDaoImpl();
	
	Vector<ExamTo> veto=null;
	boolean flag=false;
	
	public Vector<ExamTo> viewQuestion()throws DataNotFoundException{
		
		veto=edao.viewQuestion();
		
		if (veto.isEmpty()) {
			
			throw new DataNotFoundException();
			
		   }
		return veto;
		
	}
	public boolean scheduleExam(ExamTo eb)throws LoginException,ConnectionException{
		
		flag=edao.scheduleExam(eb);
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(eb==null ) {
			throw new LoginException();
			}
		return flag;
		}
	public Vector<ExamTo> viewSchedule()throws DataNotFoundException{
		
		veto=edao.viewSchedule();
        if (veto.isEmpty()) {
			
			throw new DataNotFoundException();
			
		   }
		return veto;
		}
	public boolean insertMarks(ExamTo eb)throws LoginException,ConnectionException{
		
		flag=edao.insertMarks(eb);
		 if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(eb.getLogin()==null ||eb.getLogin().equals("")) {
			throw new LoginException();
			}
		return flag;
	}
	public Vector<ExamTo > viewMarks()throws DataNotFoundException{
		
		veto=edao.viewMarks();
       if (veto.isEmpty()) {
			throw new DataNotFoundException();
			}
		return veto;
	}
	public Vector<ExamTo > viewMarksAt(String login)throws DataNotFoundException{
		
		veto=edao.viewMarksAt(login);
		if (veto.isEmpty()) {
			throw new DataNotFoundException();
			}
		return veto;
	}
	public boolean insertQuestion(ExamTo eb) throws LoginException,ConnectionException {
	
		flag=edao.insertQuestion(eb);
		 if(flag==false)
			{
				throw new ConnectionException();
				}
	       else if(eb==null) {
				throw new LoginException();
				}
			return flag;
}
	
	
	

}
